package com.hospital.new_yygh.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger2配置信息
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket adminApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApi")
                .apiInfo(adminApiInfo())
                .select()
                //只显示admin路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/admin/.*")))
                .build();

    }

    @Bean
    public Docket patientApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("patientApi")
                .apiInfo(patientApiInfo())
                .select()
                //只显示admin路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/patient/.*")))
                .build();

    }

    @Bean
    public Docket doctorApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("doctorApi")
                .apiInfo(doctorApiInfo())
                .select()
                //只显示admin路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/doctor/.*")))
                .build();

    }

    @Bean
    public Docket departmentApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("departmentApi")
                .apiInfo(departmentApiInfo())
                .select()
                //只显示admin路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/department/.*")))
                .build();

    }

    @Bean
    public Docket orderApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("orderApi")
                .apiInfo(orderApiInfo())
                .select()
                //只显示admin路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/order/.*")))
                .build();

    }

    @Bean
    public Docket scheApiConfig(){

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("scheApi")
                .apiInfo(scheApiInfo())
                .select()
                //只显示admin路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/sche/.*")))
                .build();

    }


    private ApiInfo adminApiInfo(){

        return new ApiInfoBuilder()
                .title("预约挂号系统-管理员接口文档")
                .description("本文档描述了管理员的接口")
                .version("1.0")
                .contact(new Contact("lanshi", "", "1832525707@qq.com"))
                .build();
    }

    private ApiInfo patientApiInfo() {
        return new ApiInfoBuilder()
                .title("预约挂号系统-患者接口文档")
                .description("本文档描述了患者的接口")
                .version("1.0")
                .contact(new Contact("lanshi", "", "1832525707@qq.com"))
                .build();
    }

    private ApiInfo doctorApiInfo() {
        return new ApiInfoBuilder()
                .title("预约挂号系统-医生接口文档")
                .description("本文档描述了医生的接口")
                .version("1.0")
                .contact(new Contact("lanshi", "", "1832525707@qq.com"))
                .build();
    }

    private ApiInfo departmentApiInfo() {
        return new ApiInfoBuilder()
                .title("预约挂号系统-科室接口文档")
                .description("本文档描述了科室的接口")
                .version("1.0")
                .contact(new Contact("lanshi", "", "1832525707@qq.com"))
                .build();
    }

    private ApiInfo orderApiInfo() {
        return new ApiInfoBuilder()
                .title("预约挂号系统-预约挂号接口文档")
                .description("本文档描述了预约挂号的接口")
                .version("1.0")
                .contact(new Contact("lanshi", "", "1832525707@qq.com"))
                .build();
    }

    private ApiInfo scheApiInfo() {
        return new ApiInfoBuilder()
                .title("预约挂号系统-医生排班接口文档")
                .description("本文档描述了医生排班的接口")
                .version("1.0")
                .contact(new Contact("lanshi", "", "1832525707@qq.com"))
                .build();
    }





}
